package day02.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @ClassName ReadStringDemo
 * @Description TODO
 * @Author xinghaiyang
 * @Date 2023/3/18 15:34
 * @Version 1.0
 *
 * 使用文件流从文件中读取文本数据
 **/
public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        File file = new File("./JSD2205_SE/src/day02/io/ReadStringDemo.java");
        FileInputStream fis = new FileInputStream(file);
        long length = file.length();
        byte[] data = new byte[(int)length];
        fis.read(data);
        String line = new String(data, StandardCharsets.UTF_8);
        System.out.println(line);
    }
}
